package com.skyolder.milkbee.service;

import com.skyolder.milkbee.domain.Stranger;
import com.skyolder.milkbee.repository.StrangerRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;

import javax.inject.Inject;
import java.util.List;

/**
 * Service Implementation for managing Stranger.
 */
@Service
@Transactional
public class StrangerService {

    private final Logger log = LoggerFactory.getLogger(StrangerService.class);
    
    @Inject
    private StrangerRepository strangerRepository;
    


    /**
     * Save a stranger.
     *
     * @param stranger the entity to save
     * @return the persisted entity
     */
    public Stranger save(Stranger stranger) {
        log.debug("Request to save Stranger : {}", stranger);
        Stranger result = strangerRepository.save(stranger);
        return result;
    }

    /**
     *  Get all the strangers.
     *  
     *  @param pageable the pagination information
     *  @return the list of entities
     */
    @Transactional(readOnly = true) 
    public Page<Stranger> findAll(Pageable pageable) {
        log.debug("Request to get all Strangers");
        Page<Stranger> result = strangerRepository.findAll(pageable);
        return result;
    }

    /**
     *  Get one stranger by id.
     *
     *  @param id the id of the entity
     *  @return the entity
     */
    @Transactional(readOnly = true) 
    public Stranger findOne(Long id) {
        log.debug("Request to get Stranger : {}", id);
        Stranger stranger = strangerRepository.findOne(id);
        return stranger;
    }

    /**
     *  Delete the  stranger by id.
     *
     *  @param id the id of the entity
     */
    public void delete(Long id) {
        log.debug("Request to delete Stranger : {}", id);
        strangerRepository.delete(id);
    }

	public List<Stranger> doQueryByCategoryId(List<Long> categoryIds) {
		return strangerRepository.doQueryByCategoryId(categoryIds);
	}

	public List<Stranger> findByCategoryIdAndLeaguerIdAndForbiddenTrue(Long categoryId, Long leaguerId) {
		return strangerRepository.findByCategoryIdAndLeaguerIdAndForbiddenTrue(categoryId,leaguerId);
	}
}
